﻿using UnityEngine;
using UnityEngine.UI;

namespace BToolkit
{
    public class LunPan_Cell : MonoBehaviour
    {
        public Text textPoint;
        public Text textMulti;
        public Image icon;

        public RectTransform rectTransform { get { return transform as RectTransform; } }

        public void SetContent(LunPan lunpan, int cellValue, string format = null)
        {
            if (string.IsNullOrEmpty(format))
            {
                textPoint.text = cellValue + "";
                if (cellValue < 10000)
                {
                    icon.sprite = lunpan.coinIconLevels[0];
                }
                else if (cellValue < 50000)
                {
                    icon.sprite = lunpan.coinIconLevels[1];
                }
                else if (cellValue < 300000)
                {
                    icon.sprite = lunpan.coinIconLevels[2];
                }
                else
                {
                    icon.sprite = lunpan.coinIconLevels[3];
                }
                icon.SetNativeSize();
            }
            else
            {
                textMulti.text = string.Format(format, cellValue);
            }
        }

    }
}